<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<fmt:setBundle basename="ApplicationMessage" />
<fmt:setLocale value="zh_CN" />

<sec:authentication property="principal" var="currentPrincipal" scope="page" />

<div class="modal-dialog x-modal-dialog" style="width:600px; margin-top: 150px;">

  <div class="modal-content">

    <div class="modal-header x-breadcrumb no-bottom-border clearfix">

      <h2><i class="glyphicon glyphicon-fire" title="增加课程"></i>&nbsp;&nbsp;增加课程</h2>

      <button type="button" class="close" data-dismiss="modal">&times;</button>

    </div>

    <form class="form-horizontal" method="POST" action="${ctx.host}/year-rounds/${courseRoundId}/schedules" data-validate="true">
    
      <div class="modal-body">
        <div class="form-group x-form-group">
          <label class="col-xs-4 control-label text-right">门店:</label>
          <div class="pull-left col-xs-6">
            <select name="site" class="form-control" data-validate="required">
              <option value=""></option>
              <c:forEach var="site" items="${persist.getSites(currentPrincipal.id)}">
                <option value="${site.id}">${site.name}</option>
              </c:forEach>
            </select>
          </div>
        </div>
        <div class="form-group x-form-group">
          <label class="col-xs-4 control-label text-right">区域:</label>
          <div class="pull-left col-xs-6">
            <select name="area" class="form-control" data-validate="required">
              <option value=""></option>
              <option value="common">公共区域</option>
              <option value="room">私有区域</option>
            </select>
          </div>
        </div>
        <div class="form-group x-form-group">
          <label class="col-xs-4 control-label text-right">日期:</label>
          <div class="pull-left col-xs-6">
            <input type="text" class="form-control date" name="occurDate" value="" data-validate="required"/>
          </div>
        </div>
        <div class="form-group x-form-group">
          <label class="col-xs-4 control-label text-right">时间:</label>
          <div class="pull-left col-xs-6">
            <select name="occurHour" class="form-control" data-validate="required">
              <option value=""></option>
              <c:forEach begin="10" end="20" varStatus="status">
                <c:set var="hour" value="${status.index}:00"></c:set>
                <option value="${status.index}:00" >${status.index}:00 ~ ${status.index + 1}:00</option>
              </c:forEach>
            </select>
          </div>
        </div>
        <div class="form-group x-form-group">
          <label class="col-xs-4 control-label">教练</label>
          <div class="pull-left col-xs-6">
            <select name="coach" class="form-control" data-validate="required">
              <option value=""></option>
              <c:forEach var="principal" items="${persist.coaches(currentPrincipal.id, param.site)}">
                <c:if test="${principal.value.coach}">
                  <option value="${principal.key}">${principal.value.name}</option>
                </c:if>
              </c:forEach>
            </select>
          </div>
        </div>
      </div>
      
      <div class="modal-footer clearfix">
        <button type="submit" class="btn btn-success btn-shadow btn-shadow-success x-btn">确定</button>&nbsp;&nbsp;&nbsp;&nbsp;
        <button type="button" class="btn btn-default btn-shadow btn-shadow-default x-btn" data-dismiss="modal">取消</button>
      </div>
    </form>

  </div>

</div>

<script>
$('.date').datetimepicker({
    format: 'yyyy-mm-dd',
    autoclose: true,
    language: 'zh-CN',
    todayBtn: 'linked',
    startDate: '${today}',
    todayHighlight: true,
    pickerPosition: 'bottom-right',
    minView: 'month'
  })
 
 $('select[name="occurHour"]').select2({
   placeholder : '请选择具体时间段',
   minimumResultsForSearch : 5,
   allowClear : true,
 });
 
 $('select[name="coach"]').select2({
     placeholder : '请选择教练',
     minimumResultsForSearch : 5,
     allowClear : false,
   });
 
 $('select[name="site"]').select2({
     placeholder : '请选择门店',
     minimumResultsForSearch : 5,
     allowClear : false,
 });
 
 $('select[name="area"]').select2({
     placeholder : '请选择区域',
     minimumResultsForSearch : 5,
     allowClear : false,
 });

</script>

